﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<AliyunMobileTestPlatform.Models.ProjectModel>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	项目管理
</asp:Content>
 <asp:Content ID="Content3" ContentPlaceHolderID="ImportContent" runat="server">
     <link href="../../Content/bootstrap.css" rel="stylesheet" type="text/css" />
     <link href="../../Content/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
     <link href="../../Content/CustomContainer.css" rel="stylesheet" type="text/css" />
 </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        SelectNav(1);
    </script>
    <h2>项目管理</h2>

     <p>
       <a data-toggle="modal" data-target="#createModal" class="btn">新建项目</a>
    </p>

    <div class="accordion" id="all">
    <% foreach (var item in Model) { %>
        <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#all" href="#<%:item.ID %>" >
                <%: item.ProjectName %>
              </a>               
            </div>
            <div id="<%:item.ID %>" class="accordion-body collapse">
              <div class="accordion-inner">
               <div id="info_<%:item.ID %>" style="margin:5,0,5,0">
                   <p>
                       <button type="button" data-toggle="modal" data-target="#editModal" class="btn btn-primary" onclick='OnProjectEdit(document.getElementById("info_<%:item.ID %>"))'>编辑</button>
                       <button type="button" data-toggle="modal" data-target="#delModal" class="btn btn-primary" onclick='OnDelete("project","<%:item.ProjectName %>")'>删除</button>
                   </p>
                   <h5>ID: <span><%:item.ID %></span><span style="margin-left:30px">项目名称：</span><span><%:item.ProjectName %></span></h5>
                   <p>硬件信息： <span><%:item.HardwareInfo %></span></p>
                   <p>软件信息： <span><%:item.SoftwareInfo %></span></p>
                   <p>
                       <a data-toggle="modal" data-target="#addBranchModal" class="btn" onclick='OnBranchAdd("<%:item.ProjectName %>")'>添加分支</a>
                   </p>
               </div>
               <div class="accordion" id="accordion<%:item.ID %>">
                <%foreach (var b in item.Branches)
                  { %>
                  <div class="accordion-group">
                    <div class="accordion-heading" style="margin:0,0,0,30">
                      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion<%:item.ID %>" href="#<%:item.ID %>_<%:b.ID %>">
                          <%:b.Name %>
                      </a>
                    </div>
                    <div id="<%:item.ID %>_<%:b.ID %>" class="accordion-body collapse">
                        <div class="accordion-inner">
                            <p><%:b.Repository %></p>
                            <p><button type="button" data-toggle="modal" data-target="#delModal" class="btn btn-primary" onclick='OnDelete("branch","<%:item.ProjectName %>@<%:b.Name %>")'>删除</button></p>
                        </div>
                    </div>
                  </div>
                <%} %>
              </div>
             </div>
            </div>
        </div>
    <% } %>
    </div>

<div id="editModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="editModalLabel">编辑</h3>
  </div>
  <form name="updateProject" action="Edit" method="post">
  <div class="modal-body" id="editInfo">
    <h5>ID: <span id="projectId"></span><span style="margin-left:30px">项目名称：</span><span id="projectName"></span></h5>
    <p>硬件信息： <input id="hardwareInfo" name="hardwareInfo" type="text"/></p>
    <p>软件信息： <input id="softwareInfo" name="softwareInfo" type="text"/></p>
    <input id="pidHidden" name="pid" type="hidden" />
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
    <button class="btn btn-primary" type="submit">保存</button>
  </div>
  </form>
</div>

<div id="createModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="createModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="createModalLabel">新建项目</h3>
  </div>
  <form name="createProject" action="Create" method="post">
  <div class="modal-body" id="createInfo">
    <p>项目名称：<input id="creProjName" name="creProjName" type="text"/></p>
    <p>硬件信息： <input id="crehardwareInfo" name="hardwareInfo" type="text"/></p>
    <p>软件信息： <input id="cresoftwareInfo" name="softwareInfo" type="text"/></p>
    <input id="crepidHidden" name="pid" type="hidden" />
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
    <button class="btn btn-primary" type="submit">保存</button>
  </div>
  </form>
</div>


<div id="addBranchModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addBranchModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="addBranchModalLabel">添加分支</h3>
  </div>
  <form name="addBranch" action="AddBranch" method="post">
  <div class="modal-body" id="addBranchInfo">
    <p>分支名称：<input id="addBranchName" name="addBranchName" type="text"/></p>
    <input id="beloneProjName" name="beloneProjName" type="hidden" />
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
    <button class="btn btn-primary" type="submit">保存</button>
  </div>
  </form>
</div>


<div id="delModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="delModalLabel" aria-hidden="true">
  <div class="alert alert-block alert-error fade in">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="alert-heading">警告!</h4>
    <p>删除过后无法恢复，你确定要这么做吗</p>
    <form id="delForm" action="Delete" method="post">
    <p>
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        <button class="btn btn-danger">确定</button>
    </p>
    <input type="hidden" id="delType" name="delType" />
    <input type="hidden" id="delName" name="delName" />
    </form>
  </div>
</div>
</asp:Content>

